﻿using FrameWorkSong;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class BesselPathUseDemo : MonoBehaviourSimplify
{
    public override void OnBeforeDestroy()
    {
        
    }
    public Transform TransformSelf;
 public    BasselPathTemplet basselPathTemplet;
    List<Vector3> vector3s;
    DrawGizmosBessel drawGizmosBessel;
    // Start is called before the first frame update
    void Start()
    {
     
        drawGizmosBessel = gameObject.GetComponent<DrawGizmosBessel>();
#if UNITY_EDITOR
        ReadTemplet(10);
#endif
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            StopSongTween("id");
        }
        if (Input.GetKeyDown(KeyCode.B))
        {
            StartSongTween("id");
        }
    }
#if UNITY_EDITOR 
    void ReadTemplet(float allTime)
    {
        //basselPathTemplet = (BasselPathTemplet)AssetDatabase.LoadAssetAtPath("Assets/FrameWorkSong/Data/" + "Path" + ".asset", typeof(BasselPathTemplet));
        ResLoader resLoader = new ResLoader();//资源管理器
         basselPathTemplet = resLoader.LoadAssetSync<BasselPathTemplet>("Path", "resources://Data/Path");//资源不需要后缀
       // basselPathTemplet = Resources.Load<BasselPathTemplet>("Data/Path");
        vector3s = basselPathTemplet.BasselPathPoints;
        drawGizmosBessel.vector3s = vector3s;
        float time = allTime / vector3s.Count;
        DoMovePath(TransformSelf, basselPathTemplet.BasselPathPoints, allTime,false,()=> { Debug.Log("跑完"); }, "id");
       // int i = 0;
        //OnMove();
        //void OnMove()
        //{
        //    if (i < vector3s.Count)
        //    {
        //        DoMove(TransformSelf, vector3s[i++], time, "id", OnMove);
        //    }

        //}
    }
#endif

}
